package cn.bs.allensocket.yieldthread;

/**
 * Created by Allen on 2014/11/6.
 */
public class MyYieldThreadMain {

    public static void main(String[] args){
        Thread t1 = new MyAllenThread();
        Thread t2 = new Thread(new MyRunnable());
        t1.start();
        t2.start();
    }
    static class MyAllenThread extends Thread{
        public void run(){
            for (int i = 0 ;i < 10;i++){
                System.out.println("线程1第" + i + "次执行！");
                Thread.yield();
            }
        }
    }

    static class MyRunnable implements Runnable{
        public void run(){
            for(int i = 0;i < 10;i++){
                System.out.println("线程2第" + i + "次执行");
                Thread.yield();
            }
        }
    }
}
